﻿using UnityEngine;

namespace Script.Tween
{
    public class Ease
    {
        public static Vector3 In(Vector3 start, Vector3 end, float duration, float timeCounter)
        {
            float time = timeCounter / duration;
            return start + (end - start) * (time * time * time * time);
        }

        public static Vector3 Out(Vector3 start, Vector3 end, float duration, float timeCounter)
        {
            float time = timeCounter / duration - 1;
            return start + (end - start) * (time * time * time * time * time + 1);
        }

        public static Vector3 InOut(Vector3 start, Vector3 end, float duration, float timeCounter)
        {
            float time = timeCounter / (duration / 2);
            if (time < 1)
            {
                return (end - start) / 2 * (time * time * time * time * time) + start;
            }

            time -= 2;
            return (end - start) / 2 * (time * time * time * time * time + 2) + start;
        }
        public static Vector3 Linear(Vector3 start, Vector3 end, float duration, float timeCounter)
        {
            return start + (end - start) * timeCounter / duration;
        }
    }
}